﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frame3.aspx.cs" Inherits="frame3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    void Page_Load(object sender, MenuEventArgs e)
    {
       
    }
  protected  void clickdata(object sender,  GridViewRowEventArgs e)
    {
      if(e.Row.RowType== DataControlRowType.DataRow)
      {
        DateTime date1=(DateTime)DataBinder.Eval(e.Row.DataItem,"date");
        SqlDataSource srcmo = (SqlDataSource)e.Row.FindControl("srcmo");
        srcmo.SelectParameters["date"].DefaultValue = date1.ToString();
}
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label2" runat="server" Text="Select a session" BackColor="#5D7B9D" ForeColor="White" Font-Size="Large" Font-Bold="True"></asp:Label>    
     <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource2" 
            OnRowDataBound="clickdata" AutoGenerateColumns="False" GridLines="Vertical" 
            ShowHeader="False" BackColor="White" BorderColor="#DEDFDE" 
            BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black">       
         <RowStyle BackColor="#F7F7DE" />
        <Columns>
<asp:TemplateField>
<ItemTemplate>
    <asp:Label ID="Label1" runat="server" Text='<%#Eval("date","{0:dd/MM/yyyy}") %>'  BorderWidth="1" BorderColor="Black"></asp:Label>
    <asp:GridView ID="GridView2" DataSourceID="srcmo"  AutoGenerateColumns="false" runat="server">   
<Columns> 

<asp:BoundField DataField="cinema" HeaderText="Cinema" />
<asp:HyperLinkField DataTextField="time"  DataNavigateUrlFields="sessionid,movieid,cinema,sessiontype,date" DataNavigateUrlFormatString="ticket/ticket.aspx?session={0}&movieid={1}&cinema={2}&sessiontype={3}&date={4:dd/MM/yyyy}"     HeaderText="Session Time"   Target="_blank"  ControlStyle-ForeColor="#990033" />

    </Columns>
   

    </asp:GridView>
<asp:SqlDataSource ID="srcmo" runat="server"
 ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
      SelectCommand="SELECT distinct [cinema],[time],[movieid],[sessiontype],[ticketsold],[date],session2.sessionid FROM [session2],[datesession] WHERE ([date]=@date) AND ([movieid]=@movieid) AND datesession.sessionid=session2.sessionid  ">
      <SelectParameters>
     <asp:Parameter  DbType="Date" Name="date" />
      </SelectParameters>
<SelectParameters>
 <asp:QueryStringParameter Name="movieid" QueryStringField="movieid" 
            Type="Int16" />
</SelectParameters>
      </asp:SqlDataSource>
      </ItemTemplate>
</asp:TemplateField>    
            
        </Columns>
         <FooterStyle BackColor="#CCCC99" />
         <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
         <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
         <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
         <AlternatingRowStyle BackColor="White" />
        </asp:GridView> 
  <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"  
            
            SelectCommand="SELECT DISTINCT date, movieid FROM datesession WHERE (movieid = @MovieId)">
<SelectParameters>
 <asp:QueryStringParameter Name="MovieId" QueryStringField="movieid" 
            Type="Int16" />
</SelectParameters>
      
</asp:SqlDataSource> 
    </div>
    </form>
</body>
</html>
